<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once('admin'.EXT);

class Config extends Admin {
    
    function __construct()
    {
        parent::__construct();
    }
    
    function index()
    {
        $row = $this->db->select()->from("config")->get()->row();
        
        $this->data['row']  =   $row;
        
        if($_SERVER['REQUEST_METHOD']=='POST')
        {
            $_data = array(
                'addr'  =>  $this->input->post('addr'),
                'tel'  =>  $this->input->post('tel'),
                'fax'  =>  $this->input->post('fax'),
                'email' => $this->input->post('email'),
            	'domain'	=>	$this->input->post('domain'),
            	'slogan'	=>	$this->input->post('slogan'),
            	'title'	=>	$this->input->post('title'),
            	'keywords'	=>	$this->input->post('keywords'),
            	'desc'	=>	$this->input->post('desc'),
            	'time_update'	=>	time()
            );
            if($row){
                $this->db->update('config',$_data);
                $this->db->where('id',$row->id);
            }
            else{
                $this->db->insert('config',$_data);
            }
            redirect(admin_url('config'));
        }
        
        $this->data['tpl_file']	= 'config/index';
        $this->load->view('layout/default', $this->data);
    }
}